package com.tencent.iov.cowin.befsale.clue.repository.cus.impl;

import com.github.pagehelper.Page;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueTaskDataHistory;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.ClueIntentionGradeDataRequest;
import com.tencent.iov.cowin.befsale.clue.dao.cus.OemCustomerFollowRecordDao;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.OemCustomerFollowRecord;
import com.tencent.iov.cowin.befsale.clue.domain.cus.vo.CustomerBehaviorStatistical;
import com.tencent.iov.cowin.befsale.clue.repository.cus.OemCustomerFollowRecordManager;
import com.tencent.iov.cowin.befsale.clue.value.contants.ServiceConstant;
import com.software.boot.dao.annotation.TargetDataSource;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @Describe: 总部线索跟进记录_Manager实现层
 * @author: xiamu
 * @created: 2021-12-21 18:37:32
 * @version: 1.0
 */
@Service
public class OemCustomerFollowRecordManagerImpl implements OemCustomerFollowRecordManager {

    @Autowired
    private OemCustomerFollowRecordDao oemCustomerFollowRecordDao;

    /**
     * 通过ID获取详细信息
     *
     * @param: id
     * @return: OemCustomerFollowRecord对象
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public OemCustomerFollowRecord getDetailById(Long id) {
        return oemCustomerFollowRecordDao.getDetailById(id);
    }

    /**
     * 单条数据插入OemCustomerFollowRecord
     *
     * @param request
     * @return 插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insert(OemCustomerFollowRecord request) {
        return oemCustomerFollowRecordDao.insert(request);
    }

    /**
     * 批量插入OemCustomerFollowRecord
     *
     * @param requests
     * @return 批量插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insertBatch(List<OemCustomerFollowRecord> requests) {
        return oemCustomerFollowRecordDao.insertBatch(requests);
    }

    /**
     * 单条OemCustomerFollowRecord更新
     *
     * @param request
     * @return 更新的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int update(OemCustomerFollowRecord request) {
        return oemCustomerFollowRecordDao.update(request);
    }

    /**
     * 单条OemCustomerFollowRecord删除
     *
     * @param id
     * @return 删除的条数
     */
    @Override
    public int delete(Integer id) {
        return oemCustomerFollowRecordDao.delete(id);
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request
     * @return 查询结果
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public List<OemCustomerFollowRecord> getListByParam(OemCustomerFollowRecord request) {
        return oemCustomerFollowRecordDao.getListByParam(request);
    }

    /**
     * 根据条件查询对象page记录
     *
     * @param request
     * @param rowBounds
     * @return 分页对象
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public Page<OemCustomerFollowRecord> getPageByParam(OemCustomerFollowRecord request, RowBounds rowBounds) {
        return oemCustomerFollowRecordDao.getPageByParam(request, rowBounds);
    }

    /**
     * 根据条件查询单个对象
     *
     * @param request
     * @return
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public OemCustomerFollowRecord getOneByParam(OemCustomerFollowRecord request) {
        return oemCustomerFollowRecordDao.getOneByParam(request);
    }

    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public List<CustomerBehaviorStatistical> statisticalByStatus(Date startDate, Date endDate, List<Integer> statues) {
        return oemCustomerFollowRecordDao.statisticalByStatus(startDate, endDate, statues);
    }

    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public List<CustomerBehaviorStatistical> statisticalBySecondStatus(Date startDate, Date endDate, List<Integer> secondStatues) {
        return oemCustomerFollowRecordDao.statisticalBySecondStatus(startDate, endDate, secondStatues);
    }

    /**
     * 根据状态统计记录表
     * add by zly
     * @param clueIntentionGradeDataRequest
     * @return
     */
    @Override
    public Integer getRecordFollowUpData(ClueIntentionGradeDataRequest clueIntentionGradeDataRequest) {
        return oemCustomerFollowRecordDao.getRecordFollowUpData(clueIntentionGradeDataRequest);
    }

    /**
     * 以月份分组，查询月份对应的逾期数量
     * add by zly
     * @param clueIntentionGradeDataRequest
     * @return
     */
    @Override
    public List<ClueTaskDataHistory> getRecordFollowUpHistoryData(ClueIntentionGradeDataRequest clueIntentionGradeDataRequest) {
        return oemCustomerFollowRecordDao.getRecordFollowUpHistoryData(clueIntentionGradeDataRequest);
    }
}
